# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
#import webrepl
#webrepl.start()
import socket
import network
from machine import Pin, ADC
import time
psx = ADC(Pin(33))
psy = ADC(Pin(32))
psx.atten(ADC.ATTN_11DB)
psy.atten(ADC.ATTN_11DB)

wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect('aph123', '00000000')


udp_sovket = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
while True:
    valx = psx.read()
    valy = psy.read()
    time.sleep(0.3)
    if valx < 1000:
        udp_sovket.sendto(b"1",("192.168.4.1",8007))
    elif valx > 3000:
        udp_sovket.sendto(b"2",("192.168.4.1",8007))
    elif valy < 1000:
        udp_sovket.sendto(b"3",("192.168.4.1",8007))
    elif valy > 3000:
        udp_sovket.sendto(b"4",("192.168.4.1",8007))


